package com.climber.android.commonres.ui.preview

import android.os.Parcelable
import androidx.annotation.IntDef
import com.climber.android.commonres.ui.preview.MediaPreviewType.Companion.PREVIEW_IMAGE
import com.climber.android.commonres.ui.preview.MediaPreviewType.Companion.PREVIEW_VIDEO
import kotlinx.android.parcel.Parcelize

/**
 * Created by Mikes at 2020-04-17 15:16
 */

@kotlin.annotation.Retention(AnnotationRetention.SOURCE)
@IntDef(PREVIEW_VIDEO, PREVIEW_IMAGE)
annotation class MediaPreviewType{
    companion object{
        const val PREVIEW_VIDEO = 1
        const val PREVIEW_IMAGE = 2

    }
}

@Parcelize
data class MediaPreview internal constructor(
        @MediaPreviewType val type : Int,                // 预览的文件类型
        val previewUrl : String = "",                        // 预览的文件链接（在线链接）
        val previewPath : String = "",                        // 预览的本地文件路径（优先级比previewUrl高）
        val videoThumbUrl : String = ""                      // 视频的预览图
) : Parcelable{
    companion object{
        fun previewImageMedia(previewUrl : String, previewPath: String = "") : MediaPreview =
                MediaPreview(type = PREVIEW_IMAGE,
                        previewUrl = previewUrl,
                        previewPath = previewPath)

        fun previewVideoMedia(previewUrl : String, previewPath : String = "", videoThumbUrl : String = "") : MediaPreview =
                MediaPreview(type = PREVIEW_VIDEO,
                        previewUrl = previewUrl,
                        previewPath = previewPath,
                        videoThumbUrl = videoThumbUrl)
    }
}